'use strict';
/**
 * Created by zhouzhongyuan on 2016/1/8.
 */
$app.view(["text!./login.html", 'jquery', "underscore", "jquery.form"],
  function (tpl, $, _) {
    return {
      el      : $("body").attr("class", "external-page external-alt sb-l-c sb-r-c"),
      template: _.template(tpl),
      events  : {
        "submit #contact": '_submit'
      },
      _submit : function () {
        var formData = {};
        _.each(this.$el.find("#contact").formToArray(), function (value, index) {
          formData[value.name] = value.value;
        });
        this.submit(formData);
        return false;
      },
      submit  : function (fn) {
        if (_.isFunction(fn)) {
          this.submit = fn;
        }
      },
      render  : function () {
        this.$el.html(this.template());
        return this;
      }
    }
  }
);